< previous page page_549 next page >

Page 549
shown in Figure 25.3. Browse to the appropriate database file and click OK. The selected filename and path are automatically entered into the DatabaseName property.
0549-01.jpg
Figure 25.3
You can enter a database name in the
Database property input line or choose
it from the DatabseName dialog box.
CAUTION
If you browse to the DatabaseName property at design time using the dialog box, the property includes a fully qualified path to the database's filenamefor example, C:\MyData\LMS\TMS1112.MDB. This may be dangerous because the database will be expected to be in the same exact location at runtime. Allowing some flexibility in the location of the database would be better. For that reason, set the DatabaseName property using no path (TMS1112.MDB), in which case, your program would expect to find it in the program's current directory; then use a relative path from the current directory (LMS\TMS1112.MDB). Of course, an even better solution would be to set the property from code, based on user input or some type of program initialization parameters, as in the following example:
Dim sDBLocation As String
sDBLocation = App.Path & "\MYDB.MDB"
Data1.DatabaseName = sDBLocation

Selecting a Recordset
After you set the DatabaseName property, you can specify the information you want from that database with the RecordSource property. If you intend for your Data control to work with a single table within a database, you can enter the table name or select it from the list of tables, as shown in Figure 25.4.
If you want to use only selected information from a table or to use information from multiple tables, you can use a SQL (Structured Query Language) statement in the RecordSource property. To do so, you can either set the RecordSource property to the name of a QueryDef in the database that contains a SQL statement, or enter a valid SQL statement as the value of the RecordSource property. You can use any SQL statement that creates a recordset. (You can also include functions in your SQL statement.) If you're using a QueryDef, it must have already been defined and stored in the database.
tip.gif
To make sure that your SQL statements work correctly, you can test them in Visual Data Manager. Then copy and paste to place the statements in the RecordSource property.

sarrow.gifSee "The Parts of the SQL Statement,"p. 795

 
< previous page page_549 next page >